package com.vnp.vchat.version2;

import java.util.ArrayList;

import se.emilsjolander.stickylistheaders.StickyListHeadersListView;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;

import com.vnp.vchat.R;
import com.vnp.vchat.Util.Utils;
import com.vnp.vchat.adapter.ContactAdapter;
import com.vnp.vchat.bean.ObjContact;
import com.vnp.vchat.database.MySQLiteHelper;

public class InvitePhoneActivity extends Activity implements OnClickListener{

	
	StickyListHeadersListView listContact;
	ContactAdapter adapter;
	ArrayList<ObjContact> objContacts = new ArrayList<ObjContact>();
	MySQLiteHelper db;
	TextView title;
	ImageButton btnBack;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_invite_phone);
		
		db = new MySQLiteHelper(this);
		
		objContacts = db.getContactFromDB();
		
		for (int i = 0; i < objContacts.size(); i++) {
			Log.i("PHONE", "NAME: "+objContacts.get(i).getName());
		}
		
		title = (TextView) findViewById(R.id.title);
		btnBack = (ImageButton) findViewById(R.id.btn_function1);
		btnBack.setVisibility(View.VISIBLE);
		listContact = (StickyListHeadersListView) findViewById(R.id.list_contact);
		adapter = new ContactAdapter(InvitePhoneActivity.this, objContacts);
		listContact.setAdapter(adapter);
		
		init();
		
		setFont();
	}
	
	void init(){
		title.setText("Số điện thoại");
		btnBack.setOnClickListener(this);
	}
	
	void setFont(){
		title.setTypeface(Utils.getTypefaceBold(InvitePhoneActivity.this));
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btn_function1:
			closeActivity();
			break;

		default:
			break;
		}
	}
	
	@Override
	public void onBackPressed() {
		closeActivity();
	}
	
	void closeActivity(){
		finish();
		overridePendingTransition(R.anim.over_main_right, R.anim.trans_right_out);
	}
	
}
